//1、编写 router/index.js文件
import {createMemoryHistory, createRouter, createWebHashHistory} from 'vue-router'
import framework from "../components/framework.vue";
import login from "../components/front/login.vue";

//2、配置路由表信息
const routes = [

{
    path: '/front',
    name: 'front',
    children: [
        {
            path: 'login',
            name: 'login',
            component: () => import('../components/front/login.vue'),
        },
        {
            path: 'register',
            name: 'register',
            component: () => import('../components/front/register.vue'),
        },
    ]
},
{
    path: '/framework',
    name: 'framework',
    component: framework,
    children: [
        {
            path: 'carStore',
            name: 'CarStore',
            component: () => import('/src/components/store/CarStore.vue'),
        },
        {
            path: 'edit/store/:storeId', // 路径参数只包含storeId
            name: 'StoreEdit',
            component: () => import('/src/components/store/StoreEditNew.vue'),
            props: (route) => ({
                // 显式转换storeId为数字类型
                storeId: Number(route.params.storeId),
            })
        },
        {
            path: 'new/storeEditNew',
            name: 'StoreNew',
            component: () => import('/src/components/store/StoreEditNew.vue'),
            props: (route) => ({
                // 显式转换storeId为数字类型
                storeId: null,
            })
        },
        {
            path: 'storeGoods/:storeId',
            name: 'StoreGoods',
            component: () => import('/src/components/store/StoreGoods.vue'),
            props: (route) => ({
                // 显式转换storeId为数字类型
                storeId: Number(route.params.storeId),
            })

        },
        {
            path: 'storePersonnel',
            name: 'StorePersonnel',
            component: () => import('/src/components/store/StorePersonnel.vue'),
        },
        {
            path: 'appointment',
            name: 'Appointment',
            component: () => import('/src/components/order/Appointment.vue'),
        },
        {
            path: 'goToProduct',
            name: 'Product',
            component: () => import('../components/product/ProductManagement.vue')
        },
        {
            path: 'carModel',
            name: 'CarModel',
            component: ()=>import('../components/product/CarModel.vue'),
        },
        {
            path: 'service',
            name: 'Service',
            component: ()=>import('../components/service/service.vue'),
        },
        {
            path: 'createProduct',
            name: 'CreateProduct',
            component: () => import('../components/product/CreateProduct.vue')
        },
        {
            path: 'updateProduct',
            name: 'UpdateProduct',
            component: () => import('../components/product/UpdateProduct.vue')
        },
        {
            path: 'saveService',
            name: 'SaveService',
            component: ()=>import('../components/service/saveService.vue')},
        {
            path: 'appointment', //子路由，跳转路径/framework/appointment
            name: 'Appointment',
            component: import('/src/components/order/Appointment.vue'),
        },
        {
            path: 'editService',
            name: 'EditService',
            component: ()=>import('../components/service/editService.vue'),
        },

        // 主内容区的子路由，作为其中一个页面
        {
            path: 'roleWithPermit',
            name: 'RoleWithPermit',
            component: () => import('/src/components/personnel/RoleWithPermit.vue')
        },
        {
            path: 'staffInfo',
            name: 'staffInfo',
            component: () => import('../components/personnel/StaffInfo.vue')
        },
        {
            path: 'brand',
            name: 'brand',
            component: () => import('/src/components/system/BrandInfo.vue')
        },
        {
            path: 'unitsInfo',
            name: 'unitsInfo',
            component: () => import('/src/components/system/UnitsInfo.vue')
        },
        {
            path: 'staffEdit',
            name: 'staffEdit',
            component: () => import('/src/components/personnel/StaffEdit.vue')
        },
        // 可以继续添加其他子路由

    ]
},


    // { path: '/', redirect: '/front/login' }
    { path: '/', redirect: '/framework' }
]

//创建路由器
const router = createRouter({
    history: createWebHashHistory(),
    routes,
})
export { router }